{include file="public/header" title="Telegram_Ai_Bot | 用户界面-群资源共享" annotation="header钩子"}
    <div class="dashboard-ecommerce">
        <div class="container-fluid dashboard-content ">
            <div class="row">
                <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <div class="page-header">
                        <h2 class="pageheader-title">群资源共享</h2>
                    </div>
                </div>
            </div>
            <div class="card">
                <div class="card-body">
                    <from>
                        <h5><b>*</b> 群名称</h5>
                        <div class="form-group">
                        <input type="text" class="form-control" id="qun" placeholder="请输入群链接或者群昵称" value="" required="">
                        </div>
                        <h5><b>*</b> 群类型</h5>
                        <div class="form-group type">
                            <select id="type" class="form-control form-control-sm">
                                <option value="0">请选择...</option>
                                {volist name="GroupType" id="vo"}
                                <option value="{$vo.id}">{$vo.name}</option>
                                {/volist}
                            </select>
                        </div>
                        <h5><b>*</b>是否需要加群验证</h5>
                        <div class="switch-button switch-button-success">
                            <input type="checkbox" checked="" name="is_verify" id="is_verify">
                            <span><label for="is_verify" onclick="is_verify()"></label></span>
                            
                        </div>
                        <sub>off=>不需要 on=>需要</sub>
                    </from>
                </div>
            </div>
            <div class="btn"><a href="javascript:add_share_qun()" class="btn btn-info active">提交群信息</a></div>
            
        </div>
    </div>
{include file="public/footer"  annotation="footer钩子"}
<style>
    .btn{
        margin-top:0px;
        margin-left: -10px;
    }
    .type{width:30%;}
    b{color:red;}
</style>
<script>
    function add_share_qun(){
        var type = $('#type').val();
        var is_verify = $('#is_verify').val();
        console.log(type,is_verify);
        var qun = $('#qun').val();
      if(!qun){
         msg('通知','请输入群名称或者群链接');
         return;
      }
      if(!type || type<1){
         msg('通知','请选择群类型');
         return;   
      }
      
      if(is_verify == 'off'){
          //不需要加群验证
          is_verify = 0;
      }else{
          //需要加群验证
          is_verify = 1;
      }
      
        console.log(qun,type,is_verify)
      
      $.post('/index/Api/add_share_qun',{'qun':qun,'type':type,'is_verify':is_verify},function(res){
          if(res.code>0){
            msg('提交通知',res.msg);
          }else{
            msg('提交通知',res.msg);
            setTimeout(function(){location.reload();},1000);
          }
      },'JSON');
    }
    
    function is_verify(){
      var is_verify = $('#is_verify').val()
      if(is_verify=="on"){
          $('#is_verify').val('off')
          msg('通知','不需要加群验证');
      }else{
          $('#is_verify').val('on')  
          msg('通知','需要加群验证');
      }
    }
</script>